package com.happybz.controller;

import com.happybz.utils.RedisOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Controller
@RestController
@RequestMapping("redis")
public class RedisController {

    @Autowired
    private RedisOperator redisOperator;

    @GetMapping("/set")
    public Object set(@RequestParam String key, @RequestParam String value){
        redisOperator.set(key,value);
        return "OK";
    }

    @GetMapping("/get")
    public Object get(@RequestParam String key){
        return (String)redisOperator.get(key);
    }

    @GetMapping("/delete")
    public Object delete(@RequestParam String key){
        redisOperator.del(key);
        return "OK";
    }
}
